Crate kestrel_crypto

source ·
Expand description

The Kestrel cryptography library. This library provides implementations of ChaCha20-Poly1305, X25519, SHA-256, HMAC-SHA-256 and the Noise X protocol.

The goal of this library is not to provide a general cryptographic library, but the functions provided here could certainly be used as such.

Modules

Decryption functions
Encryption functions
Library Errors

Structs

X25519 Private Key
X25519 Public Key

Enums

Functions

RFC 8439 ChaCha20-Poly1305 decrypt function. The key must be 32 bytes and the nonce must be 12 bytes The 16 byte poly1305 tag must be appended to the ciphertext Returns the plaintext
RFC 8439 ChaCha20-Poly1305 encrypt function. The key must be 32 bytes and the nonce must be 12 bytes. Returns the ciphertext
HMAC-SHA-256
Decrypt the payload key using the noise protocol. Returns the payload key, and the sender’s PublicKey
Encrypt the payload key using the noise X protocol. Passing None to ephemeral generates a new key pair. This is almost certainly what you want. Returns the handshake message ciphertext.
Derives a secret key from a password and a salt using scrypt. Recommended parameters are n = 32768, r = 8, p = 1 Parameter n must be larger than 1 and a power of 2
Generates the specified amount of bytes from a CSPRNG
SHA-256
RFC 7748 compliant X25519. k is the private key and u is the public key. Keys must be 32 bytes.
Derive an X25519 public key from a private key. The private key must be 32 bytes.

Type Definitions

Noise Payload Key